package com.pmcc.yn.web;

import com.pmcc.utils.AntdPage;
import com.pmcc.utils.ResultBean;
import com.pmcc.yn.entity.OrderList;
import com.pmcc.yn.service.OrderListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created by yaonan on 19/1/10.
 */
@RestController()
@RequestMapping("api/v1/oderlist")
@Api(value = "OderListController" , description = "订单信息的管理")
public class OrderListController {

    @Autowired
    OrderListService service;

    @ApiOperation(value = "分页查询", httpMethod = "POST", notes = "列表查询", response = ResultBean.class)
    @GetMapping(value = "queryByPage")
    public ResultBean queryByPage(@ApiParam(required = false, name = "分页对象", value = "分页参数，默认第一页10条数据")AntdPage antdPage,
                               @ApiParam(required = false, name="实体对象", value = "实体参数，可以是名字和调整人模糊查询") OrderList model) throws  Exception{
        return service.showList(antdPage, model);
    }


    /**
     * 新增
     * @return
     */
    @ApiOperation(value = "新增", httpMethod = "POST", notes = "新增", response = ResultBean.class)
    @PostMapping(value = "add")//
    public ResultBean add(@ApiParam( name = "实体对象", value = "model")OrderList model)throws Exception{
        return service.add(model);
    }



    /**
     * 修改
     * @param map
     * @return
     */
    @ApiOperation(value = "修改保存", httpMethod="POST", notes = "保存修改", response = ResultBean.class)
    @PostMapping(value= "updateById")
    public ResultBean edit(@ApiParam(required =true, name ="订单信息", value ="必须传输id")@RequestBody Map map) {
        return service.update(map);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @ApiOperation(value = "id", httpMethod="POST", notes = "假删信息", response = ResultBean.class)
    @PostMapping("deleteById")
    public ResultBean delete(@ApiParam(required =true, name ="假除角色信息", value ="id")String id) {
        return service.deleteById(id,null);
    }

    @ApiOperation(value = "查询订单详情", httpMethod = "GET", notes = "查询订单详情", response = ResultBean.class)
    @GetMapping(value = "queryOrderDetail")
    public OrderList queryOrderDetail(@ApiParam(required = true, name="订单id", value = "id")String id) {
        return service.queryOrderDetail(id);
    }

}
